//
//  DYLotteryDecisionButtonCell.m
//  DaYing
//
//  Created by DaYing  on 2023.
//  Copyright © 2023年 DaYing . All rights reserved.
//

#import "DYLotteryDecisionButtonCell.h"

@implementation DYLotteryDecisionButtonCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    // Background Code
}

- (void)setData:(id)data delegate:(id)delegate {
    _delegate = delegate;
    
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[DYLotteryDecisionButtonCellModel class]]) {
            DYLotteryDecisionButtonCellModel *model = data[@"data"];
            _model = model;
            if ([model.title isEqualToString:@"创建签文"] || [model.title isEqualToString:@"新建分组"]) {
                [_myButton setTitle:[NSString stringWithFormat:@" %@",model.title] forState:UIControlStateNormal];
                [_myButton setImage:[UIImage imageNamed:@"add"] forState:UIControlStateNormal];
            } else {
                [_myButton setTitle:[NSString stringWithFormat:@"%@",model.title] forState:UIControlStateNormal];
                [_myButton setImage:[UIImage new] forState:UIControlStateNormal];
            }
        }
    }
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(lotteryDecisionButtonCell:button:)]) {
        [_delegate lotteryDecisionButtonCell:self button:sender];
    }
}

@end


#pragma mark - Model

@implementation DYLotteryDecisionButtonCellModel

+ (DYLotteryDecisionButtonCellModel *)ittemModelWithTitle:(NSString *)title {
    DYLotteryDecisionButtonCellModel *model = [DYLotteryDecisionButtonCellModel new];
    model.title = kSafeString(title);
    return model;
}

@end
